<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <title>软件工程设计-后台管理中心</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link href="/layui/css/layui.css" rel="stylesheet">
</head>
<body onload="showTableData()">
<div class="layui-layout layui-layout-admin">
    <div th:replace="~{top::topHtml}"></div>
    <div th:replace="~{nav::navHtml}"></div>
    <div class="layui-body">
        <!-- 内容主体区域 -->
        <div style="padding: 15px;">
            <blockquote class="layui-elem-quote layui-text">
                软件工程设计
            </blockquote>
            <div class="layui-card layui-panel">
                <div style="padding: 15px;">
                    <blockquote class="layui-elem-quote layui-text">
                        软件工程设计
                    </blockquote>
                    <div class="layui-card layui-panel">
                        <table class="layui-table">
                            <!-- 表头 -->
                            <thead>
                            <tr>
                                <th>年级</th>
                                <th>班级</th>
                                <th>姓名</th>
                                <th>组长</th>
                                <th>项目名称</th>
                                <th>分数</th>
                            </tr>
                            </thead>
                            <!-- 表体 -->
                            <tbody id="tableData">

                            </tbody>
                        </table>
                    </div>
                    <div id="page" style="text-align: center; margin-top: 10px;"></div>
                </div>
            </div>
            <br><br>
        </div>
    </div>
    <div th:replace="~{footer::footerHtml}"></div>
</div>

<script src="/layui/layui.js"></script>
<script src="/js/jquery-3.3.1.min.js"></script>
<script src="/encrypt/crypto-js.min.js"></script>
<script src="/encrypt/encrypt-key.js"></script>


<script>
    function getStuDetail(id) {
        localStorage.setItem("stuIdGetDetail",id)
        window.location.href = "/ltj/stuInfoDetail"
    }
</script>


<script>
    let pageNum = 1
    function showTableData() {
        $.post("/ltj/getBasicProjectInfo?pageNum="+pageNum, function (res) {
            let resStr = decryptData(res.data)
            let jsonStr = JSON.parse(resStr)
            let dataTotal = jsonStr.total
            let dataSize = jsonStr.pageSize
            let data = jsonStr.list
            let tableBody = ""
            for (let i = 0; i < data.length; i++) {
                tableBody += '<tr>'
                tableBody += '<td> ' + data[i].classGrade + ' </td>'
                tableBody += '<td>' + data[i].className + '</td>'
                tableBody += '<td>'
                tableBody += '<span style="cursor: pointer" onClick="getStuDetail(' + data[i].stuId + ')">'
                tableBody += '<i class="layui-icon layui-icon-about"></i>' + data[i].stuName + ''
                tableBody += '</span>'
                tableBody += '</td>'
                tableBody += '<td>' + data[i].leaderName + '</td>'
                tableBody += '<td>' + data[i].projectName + '</td>'
                tableBody += '<td>' + data[i].basicScore + '&ensp;&ensp;'
                tableBody += '<span style="cursor: pointer" onclick="showScoreDetail(' + data[i].stuId + ')">'
                tableBody += '<i class="layui-icon layui-icon-about"></i>分数详情'
                tableBody += '</span>'
                tableBody += '</td>'
                tableBody += '</tr>'
            }
            $("#tableData").html(tableBody)
            layui.use(['table', 'laypage'], function () {
                var table = layui.table;
                var laypage = layui.laypage;

                // 渲染表格
                table.render({
                    elem: '.layui-table',
                    even: true, // 开启隔行背景
                    page: true // 开启分页
                });

                // 监听分页器的页码点击事件
                laypage.render({
                    elem: 'page', // 分页器的容器ID
                    count: dataTotal, // 数据总数
                    limit: dataSize, // 每页显示的数据条数
                    first: '首页',
                    curr: Number(jsonStr.pageNum),
                    last: '尾页',
                    layout: ['count', 'prev', 'page', 'next'],
                    jump: function (obj,first) {
                        if (!first){
                            pageNum = obj.curr
                            showTableData()
                        }else {

                        }
                    }
                });
            });
        })
    }


    function showScoreDetail(id) {
        localStorage.setItem("stuId", id)
        $.post("/ltj/getStudentInfoById?id=" + id, function (res) {
            let resData = JSON.parse(decryptData(res.data))
            layui.use(function () {
                var layer = layui.layer;
                        layer.open({
                            type: 2,
                            title: '<i class=\'layui-icon layui-icon-username\'></i>'+resData.stuName+'的分数详情',
                            shadeClose: true,
                            maxmin: true, //开启最大化最小化按钮
                            area: ['600px', '260px'],
                            content: '/ltj/scoreDetail'
                        });
                })
            });
    }
</script>

<script>
    //JS
    layui.use(['element', 'layer', 'util'], function () {
        var element = layui.element;
        var layer = layui.layer;
        var util = layui.util;
        var $ = layui.$;

        //头部事件
        util.event('lay-header-event', {
            menuLeft: function (othis) { // 左侧菜单事件
                layer.msg('展开左侧菜单的操作', {icon: 0});
            },
            menuRight: function () {  // 右侧菜单事件
                layer.open({
                    type: 1,
                    title: '更多',
                    content: '<div style="padding: 15px;">处理右侧面板的操作</div>',
                    area: ['260px', '100%'],
                    offset: 'rt', // 右上角
                    anim: 'slideLeft', // 从右侧抽屉滑出
                    shadeClose: true,
                    scrollbar: false
                });
            }
        });
    });
</script>
</body>
</html>